<{if !$_is_singlepage}>

<form method="POST" action="index.php?app=b2c&ctl=admin_goodscollection&act=save" class="tableform" id="form_member_lv">
<div class="division">

	<table cellpadding="0" cellspacing="0"  class="gridlist">
		<col style="width:20%"></col>
		<col style="width:35%"></col>
		<col style="width:20%"></col>
		<!--<col style="width:10%"></col>-->
		<col style="width:25%"></col>

		<thead>
		<tr>
			<th><{t}>货号<{/t}></th>
			<th><{t}>商品名称<{/t}></th>
			<th><{t}>计划数量<{/t}></th>
			<!--<th><{t}>购买数量<{/t}></th>-->
			<th><{t}>集货数量<{/t}></th>
		</tr>
		</thead>
		<tbody>
		<{foreach from=$info item=item key=key}>
		<tr>
			<td><{$item.bn}></td>
			<td><{$item.name}></td>
			<td><{$item.has_confirm_num}></td>
			<!--<td><{$item.quantity}></td>-->
			<td>
				<{input type="unsigned" name="data[{$key}][gc_confirm_num]" value=$item.gc_confirm_num q_data=$item.has_confirm_num size="4" placeholder=$item.gc_confirm_num onblur="check(this);"}>
				<input type="hidden" name="data[<{$key}>][obj_id]" value="<{$item.obj_id}>"/>
				<input type="hidden" name="data[<{$key}>][bn]" value="<{$item.bn}>"/>
				<input type="hidden" name="mainOrder_id" value="<{$item.mainOrder_id}>"/>
			</td>
		</tr>
		<{/foreach}>
		<tr>
			<td colspan="5"></td>
		</tr>
		<tr>
			<td><{t}>备注:<{/t}></td>
			<td colspan="4">
				<{input type="textarea" class="inputstyle" name="memo" value=$item.memo style="width:98%" rows=7 }>
				<input type="hidden" name="gc_id" value="<{$gc_id}>" />
			</td>
		</tr>
		</tbody>
	</table>

</div>
</form>
<{area inject='.mainFoot'}>
     <div class="table-action">
	<!--<{button type="button" label=$___b2c="保存"|t:'b2c' id="member_lv-form-submit"}>
	<{button type="button" label=$___b2c="集货完成"|t:'b2c' id="member_lv-form-submit"}>-->
	<{button label=$___b2c="保存"|t:'b2c' class="btn-primary" id="btn-save1" onclick="subOrderForm(event,1)"}>
	<{button label=$___b2c="集货完成"|t:'b2c' class="btn-primary" id="btn-save2" onclick="subOrderForm(event,2)"}>
</div>
<{/area}>





<script>
/*(function(){
	var _form = $('form_member_lv');
	var btn =$('member_lv-form-submit');
	var finder = finderGroup['<{$env.get._finder.finder_id}>'];

	_form.store('target',{
		onSuccess:function(response){
			var hash_res_obj = JSON.decode(response);

			if (hash_res_obj.success != undefined && hash_res_obj.success != "")
			{
				try{
					var _dialogIns = btn.getParent('.dialog').retrieve('instance');
				}catch(e){}

				if(_dialogIns)
				{
					_dialogIns.close();
					window.finderGroup['<{$env.get._finder.finder_id}>'].refresh();
				}
			}

		}
	});

	    btn.addEvent('click',function(){
		    _form.fireEvent('submit',{stop:$empty});
		});

})();*/

(function(){

	var btn1=$('btn-save1');
	var btn2=$('btn-save2');
	var _form=$('form_member_lv');
	if(!_form)return;
	var _formActionURL=_form.get('action');
	subOrderForm = function (event,sign){
		//var target={};
		//_form.store('target',target);
		_form.set('action',_formActionURL+'&but='+sign);//.fireEvent('submit',new Event(event));

		_form.store('target',{
			onSuccess:function(response){
				var hash_res_obj = JSON.decode(response);

				if (hash_res_obj.success != undefined && hash_res_obj.success != "")
				{
					try{
						var _dialogIns = btn1.getParent('.dialog').retrieve('instance');
						var _dialogIns = btn2.getParent('.dialog').retrieve('instance');
					}catch(e){}

					if(_dialogIns)
					{
						_dialogIns.close();
						window.finderGroup['<{$env.get._finder.finder_id}>'].refresh();
					}
				}

			}
		});

	};

	btn1.addEvent('click',function(){
		_form.fireEvent('submit',{stop:$empty});
	});
	btn2.addEvent('click',function(){
		_form.fireEvent('submit',{stop:$empty});
	});
})();


function check(obj){
	var gc_confirm_num = obj.get('value');
	var quantity = obj.get('q_data');
	if(isNaN(gc_confirm_num)){
		obj.set('value',quantity);
	}
	if(gc_confirm_num<0){
		obj.set('value',quantity);
	}
	if(gc_confirm_num>quantity){
		obj.set('value',quantity);
	}
}
</script>

<{/if}>
